#pragma once
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <iostream>
#include <string.h>

#define RDSIZE 1024
#define WRSIZE 1024
#define filename "NamePipe"

enum Error
{
    File_creation_failed = 10
    ,File_open_failed
    ,File_destruction_failed
    ,File_close_failed
};
class PipeInit
{
public:
    PipeInit()
    {
        //创建管道文件
        int n = mkfifo(filename, 0664);
        if(n < 0)
        {
            perror(filename);
            exit(File_creation_failed);
        }
    }

    ~PipeInit()
    {
        int n = unlink(filename);
        if(n < 0)
        {
            exit(File_destruction_failed);
        }
    }
};
